﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;

namespace SobFS.Common.Database
{
    public class DbCacheHelper
    {
        public static void DeleteCache(string cacheKey)
        {
            HttpRuntime.Cache.Remove(cacheKey);
        }

        public static object GetCache(string cacheKey)
        {
            return HttpRuntime.Cache[cacheKey];
        }

        public static void SetCache(string cacheKey, object value)
        {
            HttpRuntime.Cache.Insert(cacheKey, value);
        }

        public static void SetCache(string cacheKey, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration)
        {
            HttpRuntime.Cache.Insert(cacheKey, value, null, absoluteExpiration, slidingExpiration);
            
        }

        public static void SetCache(string cacheKey, object value, TimeSpan slidingExpiration)
        {
            HttpContext.Current.Cache.Insert(cacheKey, value, null, Cache.NoAbsoluteExpiration, slidingExpiration);
        }

    }
}
